/**
 * Nuxt.js 配置文件
 * @author chaiyf
 * @date 2022-01-06 23:47
 */
import authRooters from './routers'

/**
 * 路由处理
 * @author chaiyf
 * @date 2022-01-07 11:25
 */
function routerDeal (routers, pipe) {
  routers.map(route => {
    route.component = pipe(route.component)
    Array.isArray(route.children) && (route.children = routerDeal(route.children, pipe))
  })
  return routers
}

module.exports = {
  router: {
    linkActiveClass: 'active',
    extendRoutes (routes, resolve) {
      const pipe = path => resolve(__dirname, `pages/${path}`)

      const appRoutes = routerDeal(authRooters, pipe)

      routes.splice(0)
      routes.push(...appRoutes)
    }
  },
  plugins: [
    '~/plugins/request.js'
  ]
}
